/* GNU Mailutils -- a suite of utilities for electronic mail
   Copyright (C) 1999, 2000, 2001, 2005, 2007 Free Software Foundation, Inc.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 3 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General
   Public License along with this library; if not, write to the
   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301 USA */




/*!
\Author  Ice and Magic
\file main.cc Entrée du programme principal
\date 20 Avril 2011
\brief Ce programme cherche les nombres narcissiques d'Amstrong
*/

#include <iostream>
#include <set>

#include <cstdio>	// sscanf
#include <cstdlib>	// exit and EXIT_SUCCESS
#include "smallbrain.h"	// includes all headers
using namespace std;

extern __type		power_matrix[__CAPACITY][__DIGITS];

int
main(int argc, char** argv){
Silhouette	s(0);
init_powers();
#ifdef FULL_VERBOSE
print_powers();
#endif


__type lb=0,ub=0;

switch(argc){
case	1	:	lb=1;
			ub=0xffffffffffffffff;
			break;
case	3	:
			sscanf(argv[2],"%llu",&ub);
			if(ub==0)
				sscanf(argv[2],"%llx",&ub);

			sscanf(argv[1],"%llu",&lb);
			if(lb==0)
				sscanf(argv[1],"%xllx",&lb);

			break;
case	2	:	
			
			sscanf(argv[1],"%llu",&lb);
			if(lb==0)
				sscanf(argv[1],"%llx",&lb);
			break;
	default	:
		usage();
		exit(EXIT_SUCCESS);
}

lb=__MAX(lb,1);

cout<<"\n Search space's set to [ "<<lb<<" .. "<<ub<<" ]\n";

try{
	timer	t;
	i_collector	c(__MIN(lb,ub),__MAX(lb,ub));
	t.start();
	c.collect();
	t.end();
	c.print();
	t.print();
}
catch(...){
	cout<<"\nSomething going really wrong  here!\n";
	exit(EXIT_FAILURE);
	}
return EXIT_SUCCESS;
}


